import {ElMessage, ElMessageBox} from "element-plus";
import {axios} from "@core";
import qs from "qs";

// 防抖
const debounce = (fn, delay) => {
  let timer = null;
  return function () {
      let context = this;
      let args = arguments;
      clearTimeout(timer);
      timer = setTimeout(function () {
        fn.apply(context, args);
      }, delay);
  }
}

//删除文件
const delImg = (fileName) => {
  axios.post( /* 接口 */'', qs.stringify({ fileFileName: fileName }))
    .then((response) => {
      if (response.status == "200") {
        ElMessage({
          type: "success",
          message: "删除成功!",
        });
      }
    })
    .catch((error) => {
      ElMessage({
        message: error.message,
        type: "error",
      });
    });
}

export {
  delImg,
  debounce
}